/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            shopReturnAddressManageInfo: {
                shopReturnAddresss: [],
                total: 0,
                records: 1,
                moreCondition: false,
                addressId: '',
                conditions: {
                    levelName: '',
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            $that._listShopReturnAddresss(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('shopReturnAddressManage', 'listShopReturnAddress', function (_param) {
                $that._listShopReturnAddresss(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listShopReturnAddresss(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listShopReturnAddresss: function (_page, _rows) {
                $that.shopReturnAddressManageInfo.conditions.page = _page;
                $that.shopReturnAddressManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.shopReturnAddressManageInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/shopReturnAddress/queryShopReturnAddress',
                    param,
                    function (json, res) {
                        var _shopReturnAddressManageInfo = JSON.parse(json);
                        $that.shopReturnAddressManageInfo.total = _shopReturnAddressManageInfo.total;
                        $that.shopReturnAddressManageInfo.records = _shopReturnAddressManageInfo.records;
                        $that.shopReturnAddressManageInfo.shopReturnAddresss = _shopReturnAddressManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.shopReturnAddressManageInfo.records,
                            dataCount: $that.shopReturnAddressManageInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddShopReturnAddressModal: function () {
                vc.emit('addShopReturnAddress', 'openAddShopReturnAddressModal', {});
            },
            _openEditShopReturnAddressModel: function (_shopReturnAddress) {
                vc.emit('editShopReturnAddress', 'openEditShopReturnAddressModal', _shopReturnAddress);
            },
            _openDeleteShopReturnAddressModel: function (_shopReturnAddress) {
                vc.emit('deleteShopReturnAddress', 'openDeleteShopReturnAddressModal', _shopReturnAddress);
            },
            _queryShopReturnAddressMethod: function () {
                $that._listShopReturnAddresss(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.shopReturnAddressManageInfo.moreCondition) {
                    $that.shopReturnAddressManageInfo.moreCondition = false;
                } else {
                    $that.shopReturnAddressManageInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
